<?php
	$action_list = $this->action_list;
	$role_list = $this->role_list;
	$user_list = array();
	foreach ($this->user_list as $user) {
		$user_list[$user['id']] = $user['username'];
	}
	if ($action_list){
		echo "<form method = 'Post'>";
		echo "Chọn nhân viên : ";
		echo $this->formSelect('user',$this->user_id,array('onchange' => "javascript:window.location = '/admin/permission?user_id=' + this.value"),$user_list);
		echo "<br />";
		echo "<table width = 100% class='table table-bordered table-striped'>";
		echo "<tr class = 'tr2'><td align = 'center'>Chức năng</td><td align = 'center'>Quyền</td></tr>";
		$class = 'tr3';
		foreach ($action_list as $key => $action) {
			if ($action){
				echo "<tr class='" . $class . "'>";
				echo "<td rowspan = '" . count($action) . "' width = '30%' valign = 'middle'>". $key . "</td>";
				$flag = true;
				foreach ($action as $value) {
					if (!$flag){
						echo "<tr class='" . $class . "'>";
					}
					if (in_array($value['id'], $role_list)){
						echo "<td><input type='checkbox' name='role_list[]' checked = 'checked' label = '" . $value['name'] . "' value = '" . $value['id'] . " '>" . $value['name'] . "</td>";
					}else{
						echo "<td><input type='checkbox' name='role_list[]' label = '" . $value['name'] . "' value = '" . $value['id'] . " '>" . $value['name'] . "</td>";
					}
					if (!$flag){
						echo "</tr>";
					}
					$flag = false;
				}
				$class = ($class == 'tr3')?('tr4'):('tr3');
				echo "<tr>";
			}
		}
		echo "</table>";
		echo $this->formSubmit('submit','Đồng ý',array('class' => 'btn_submit'));
		echo "</form>";
	}
